package com.yonyou.pmclouds.plan.processor;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.plan.entity.ProjectPlanVO;
import org.apache.commons.lang3.StringUtils;

public class PlanRootProcessor implements SingleProcessor<ProjectPlanVO> {
    private ProjectPlanVO parent;

    public PlanRootProcessor(ProjectPlanVO parent) {
        this.parent = parent;
    }

    @Override
    public void process(ProjectPlanVO vo, ProjectPlanVO orig) throws BusinessException {
        if (StringUtils.isEmpty(vo.getPkParent())) {
            vo.setPkRoot(vo.getPkPlan());
        } else {
            vo.setPkRoot(parent.getPkRoot());
        }
    }
}
